
#include "iostream"
#include "vector"
#include "unordered_map"
#include "algorithm"
#include "string"
#include "list"
class Solution{
public:
    bool is_zimu(char a){
        return (a>='a'&&a<='z')||(a>='A'&&a<='Z');
    }
    bool same(char a,char b){
        return a==b||a-32==b||a==b-32;
    }
    bool is_huiwen(std::string& s){
        if(!is_zimu(s[0])){
            return false;
        }
        if(!is_zimu(s[s.size()-1])){
            return false;
        }
        int i=0,j=s.size()-1;
        while(j>i){
            if(s[0]=='M'){
//                int a=1+1;
                printf("");
            }
            if(!same(s[i],s[j])){
                return false;
            }
            i++;
            while (!is_zimu(s[i])&&j>i){
                i++;
            }
            j--;
            while (!is_zimu(s[j])&&j>i){
                j--;
            }
        }
    }
    int count_zimu(std::string& s){
        int cnt=0;
        for(auto c:s){
            if(is_zimu(c)){
                cnt++;
            }
        }
        return cnt;
    }
    void iter(std::string&s){
        for(int i=s.size();i>0;i--){
            for(int off=0;off<s.size()-i+1;off++){
                std::string s1=s.substr(off,i);
                if(is_huiwen(s1)){
                    std::cout<<count_zimu(s1)<<std::endl;
                    std::cout<<s1<<std::endl;
                    return;
                }
            }
        }
    }
    void run(){
        std::string s;
        while(1){
            char c=std::cin.get();
            if(c!=EOF){
                s+=c;
            }else{
                break;
            }
        }
        iter(s);
    }
};

int main() {
//    bool cur_num= true;
Solution().run();
    return 0;
}

